package com.lv.controller;

import com.lv.data.Result;
import com.lv.dto.SellerDto;
import com.lv.enums.ResultEnum;
import com.lv.service.SellerService;
import com.lv.vo.SellerVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("seller")
public class SellerController {

    @Resource
    private SellerService ss;

    @PostMapping("get")
    public Result<SellerDto> getSellerByName(@RequestParam("sellerId") String sellerId){
        SellerVo vo = ss.getSellerByName(sellerId);
        return Result.OK().setData(vo);
    }

    //注册
    @PutMapping
    public Result insertsell(@RequestBody SellerVo vo){
        SellerVo sellerId = ss.getSellerByName(vo.getSellerId());
        if (sellerId == null){
            ss.insertsell(vo);
            return Result.OK();
        }
        return Result.response(ResultEnum.REGISTER_ALREADY);
    }


}
